-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upload duration logic #281
Conversation
src/android/AckDatabase.java
Outdated
database.execSQL("ALTER TABLE upload_events ADD COLUMN uploadDuration INTEGER NOT NULL DEFAULT 0"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of storing uploadDuration
, why don't we store the startTime
and endTime
. The uploadDuration
is calculated from these values. Normally it is better to save the values from which it calculated rather than the value itself. (Example saving the date of birth in a db rather than the age as age can be calculated with the dob)
If we save the the starting and ending times, we can then calculate the uploadDuration and return it alongside the ending time also to the JS and set our uploadedAt
to the returned ending time value.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DOB is saved instead of age because age changes, here the uploadDuration
will not change. I agree that we need to send the uploadedAt
value also but I think it is better that we calculate the uploadDuration on the plugin side which will be calculated immediately after the upload instead of waiting for the JS side to wait for the values to do the calculations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes my suggestion was to calculate the uploadDuration
on the plugin side itself and not calculate it on the JS side but to save the values from which we derive the uploadDuration
in the db and return the uploadDuration
AND the uploadedAt
time also.
I gave the age as an example. Other examples can be keeping the buyingPrice
and sellingPrice
then derive the profit
from it althought the profit won't change. In this case the uploadDuration
won't change but saving the start and end times gives more information than just the uploadDuration
.
src/android/AckDatabase.java
Outdated
database.execSQL("ALTER TABLE upload_events ADD COLUMN uploadDuration INTEGER NOT NULL DEFAULT 0"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DOB is saved instead of age because age changes, here the uploadDuration
will not change. I agree that we need to send the uploadedAt
value also but I think it is better that we calculate the uploadDuration on the plugin side which will be calculated immediately after the upload instead of waiting for the JS side to wait for the values to do the calculations.
src/android/AckDatabase.java
Outdated
public void migrate(@NonNull SupportSQLiteDatabase database) { | ||
database.execSQL("ALTER TABLE upload_events ADD COLUMN uploadDuration INTEGER NOT NULL DEFAULT 0"); | ||
database.execSQL("ALTER TABLE upload_events ADD COLUMN startUploadTime INTEGER NOT NULL DEFAULT 0"); | ||
database.execSQL("ALTER TABLE upload_events ADD COLUMN endUploadTime INTEGER NOT NULL DEFAULT 0"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
database.execSQL("ALTER TABLE upload_events ADD COLUMN endUploadTime INTEGER NOT NULL DEFAULT 0"); | |
database.execSQL("ALTER TABLE upload_events ADD COLUMN finishUploadTime INTEGER NOT NULL DEFAULT 0"); |
NSURLSessionConfiguration* configuration = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:[[NSBundle mainBundle] bundleIdentifier]]; | ||
configuration.HTTPMaximumConnectionsPerHost = FileUploader.parallelUploadsLimit; | ||
configuration.sessionSendsLaunchEvents = NO; | ||
self.manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration]; | ||
__weak FileUploader *weakSelf = self; | ||
[self.manager setTaskDidCompleteBlock:^(NSURLSession * _Nonnull session, NSURLSessionTask * _Nonnull task, NSError * _Nullable error) { | ||
NSString* uploadId = [NSURLProtocol propertyForKey:kUploadUUIDStrPropertyKey inRequest:task.originalRequest]; | ||
NSDate *startTime = weakSelf.uploadStartTimes[uploadId]; | ||
NSTimeInterval duration = [[NSDate date] timeIntervalSinceDate:startTime]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The format/accuracy is same as android?
No description provided.